#pragma once

#include "../base/obj.h"
#include "../container/ordered_map.h"
#include <functional>
#include <string>
#include <unordered_map>

OPEN_JLIB_NS


struct RadioStation : public Obj {

	typedef std::function<bool(void*)> func_t;

public:
  bool init () noexcept { return true; }

  u64 subscribe (const std::string& channel, func_t listener);

  uwl unsubscribe (const std::string& channel);

	uwl unsubscribe (const std::string& channel, u64 id);

  uwl clear (const std::string& channel);

  uwl broadcast (const std::string& channel, void* arg = nullptr);

protected:
  std::unordered_map<std::string, ordered_map<u64, func_t>> _channels;
  u64 _seed;
};


CLOSE_JLIB_NS

